<?php
require 'inc_security.php';
//Kiem tra quyen addedit
checkPermission('add');
$catBase = new Category;
$list_cat = array(''=>' - Chọn danh mục - ');
$arrCat = $catBase->list_categories(0,'cat_active = 1 AND cat_type="'.$bg_table.'"','cat_id,cat_name,cat_type','cat_id ASC');
foreach($arrCat as $i=>$cat){
    $tt = '';
    for($j=0;$j<$cat["level"];$j++) $tt .= '|--';
    $list_cat[$cat["cat_id"]] = $tt . $cat["cat_name"];
}
$list_instock_status = array(0=>'Hết hàng',1=>'Còn hàng',2=>'Sắp về',3=>'Sắp ra mắt');

$myform = new generate_form();
$myform->add('pro_cat_id','pro_cat_id',1,0,0,1,'Chưa chọn danh mục');
$myform->add('pro_type','pro_type',1,0,1);
$myform->add('pro_name','pro_name',0,0,'',1,'Chưa nhập tên sản phẩm');
$myform->add('pro_price','pro_price',1,0,68000000);
$myform->add('pro_warranty','pro_warranty',0,0,'');
$myform->add('pro_goldwarranty','pro_goldwarranty',1,0,0);
$myform->add('pro_promotion','pro_promotion',0,0,'');
$myform->add('pro_image','imu',0,0,'',1,'Chưa chọn ảnh đại diện');
//$myform->add('pro_slides','pro_slides',0,0,'');
//$myform->add('pro_colors','pro_colors',0,0,'');
$myform->add('pro_videos','pro_videos',0,0,'');
$myform->add('pro_package','pro_package',0,0,'');
$myform->add('pro_details','pro_details',0,0,'');
$myform->add('pro_instock_status','pro_instock_status',1,0,1);
$myform->add('pro_instock_number','pro_instock_number',1,0,0);
$pro_release_date = getValue('pro_release_date','str','POST','');
$pro_release_date = convertDateTime($pro_release_date);
$myform->add('pro_release_date','pro_release_date',1,1,0);
$myform->add('pro_tags','pro_tags',0,0,'');
$myform->add('pro_general_os','pro_general_os',0,0,'');
$myform->add('pro_general_language','pro_general_language',0,0,'');
$myform->add('pro_display_type','pro_display_type',0,0,'');
$myform->add('pro_display_color','pro_display_color',0,0,'');
$myform->add('pro_display_standard','pro_display_standard',0,0,'');
$myform->add('pro_display_resolution','pro_display_resolution',0,0,'');
$myform->add('pro_display_width','pro_display_width',0,0,'');
$myform->add('pro_display_induction','pro_display_induction',0,0,'');
$myform->add('pro_cam_primary','pro_cam_primary',0,0,'');
$myform->add('pro_cam_second','pro_cam_second',0,0,'');
$myform->add('pro_cam_flash','pro_cam_flash',0,0,'');
$myform->add('pro_cam_feature','pro_cam_feature',0,0,'');
$myform->add('pro_cam_filming','pro_cam_filming',0,0,'');
$myform->add('pro_cam_videocall','pro_cam_videocall',0,0,'');
$myform->add('pro_cpuram_speed','pro_cpuram_speed',0,0,'');
$myform->add('pro_cpuram_core','pro_cpuram_core',0,0,'');
$myform->add('pro_cpuram_chipset','pro_cpuram_chipset',0,0,'');
$myform->add('pro_cpuram_ram','pro_cpuram_ram',0,0,'');
$myform->add('pro_cpuram_graphic','pro_cpuram_graphic',0,0,'');
$myform->add('pro_storage_contacts','pro_storage_contacts',0,0,'');
$myform->add('pro_storage_rom','pro_storage_rom',0,0,'');
$myform->add('pro_storage_memorycard','pro_storage_memorycard',0,0,'');
$myform->add('pro_storage_memorycardsupport','pro_storage_memorycardsupport',0,0,'');
$myform->add('pro_design_style','pro_design_style',0,0,'');
$myform->add('pro_design_size','pro_design_size',0,0,'');
$myform->add('pro_design_weight','pro_design_weight',1,0,0);
$myform->add('pro_pin_type','pro_pin_type',0,0,'');
$myform->add('pro_pin_capacity','pro_pin_capacity',0,0,'');
$myform->add('pro_pin_removable','pro_pin_removable',1,0,1);
$myform->add('pro_connect_3g','pro_connect_3g',0,0,'');
$myform->add('pro_connect_4g','pro_connect_4g',0,0,'');
$myform->add('pro_connect_simtype','pro_connect_simtype',0,0,'');
$myform->add('pro_connect_duasim','pro_connect_duasim',0,0,'');
$myform->add('pro_connect_wifi','pro_connect_wifi',0,0,'');
$myform->add('pro_connect_gps','pro_connect_gps',0,0,'');
$myform->add('pro_connect_bluetouth','pro_connect_bluetouth',0,0,'');
$myform->add('pro_connect_gprs','pro_connect_gprs',1,0,1);
$myform->add('pro_connect_nfc','pro_connect_nfc',1,0,1);
$myform->add('pro_connect_jack','pro_connect_jack',0,0,'');
$myform->add('pro_connect_usb','pro_connect_usb',0,0,'');
$myform->add('pro_connect_other','pro_connect_other',0,0,'');
$myform->add('pro_connect_chargprot','pro_connect_chargprot',0,0,'');
$myform->add('pro_entertainment_movie','pro_entertainment_movie',0,0,'');
$myform->add('pro_entertainment_player','pro_entertainment_player',0,0,'');
$myform->add('pro_entertainment_recording','pro_entertainment_recording',1,0,1);
$myform->add('pro_entertainment_fm','pro_entertainment_fm',0,0,'');
$myform->add('pro_entertainment_other','pro_entertainment_other',0,0,'');
$myform->add('pro_showhome','pro_showhome',1,0,0);
$myform->add('pro_active','pro_active',1,0,0);

$myform->addTable($bg_table);
$myform->removeHTML(0);
$action = getValue('action','str','POST','');
if($action == 'execute'){
   $pro_name = getValue('pro_name','str','POST','');
   $pro_alias = getValue('pro_alias','str','POST','');
   $pro_alias = get_alias($pro_alias,$pro_name,$bg_table,$id_field,$alias_field);
   $myform->add('pro_alias','pro_alias',0,1,'');
   
   //sản phẩm liên quan
   $pro_accessories = getValue('pro_relate_list','arr','POST','');
   if(!empty($pro_accessories)){
      $pro_accessories = implode(',',$pro_accessories);
   }else{
      $pro_accessories = '';
   }
   $myform->add('pro_accessories','pro_accessories',0,1,'');
   
   $slides = getValue('slides','arr','POST',null);
   $pro_slides = implode(',',$slides);
   $myform->add('pro_slides','pro_slides',0,1,'');
   
   $attribute_value = array();
   $attribute_val = getValue('attribute_val','arr','POST','');
   if($attribute_val){
     foreach($attribute_val as $value){
         $attribute_sls = array();
         $attribute_sls['attribute_color'] = getValue('attribute_color_'.$value,'str','POST','');
         $attribute_sls['attribute_price'] = getValue('attribute_price_'.$value,'str','POST','');
         $attribute_value[] = $attribute_sls;
     }
     $str_attribute = base64_encode(json_encode($attribute_value));
     $myform->add('pro_colors','str_attribute',0,1,'');
   }
   
    $bg_errorMsg .= $myform->checkdata();
    if($bg_errorMsg == ''){
        $db_insert = new db_execute_return();
        $last_id = $db_insert->db_execute($myform->generate_insert_SQL());
        //Add seo meta
        addSeoMeta($last_id,$bg_table);
        //ghi lai log nguoi add
        log_add($last_id,$bg_table);
        //redirect theo action cua nut nguoi dung click
        form_redirect($last_id);
    }
}
?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="vi" lang="vi" xmlns:og="http://ogp.me/ns#" xmlns:fb="https://www.facebook.com/2008/fbml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<?=$load_header?>
</head>
<body>
<div class="wrapper">
   <div class="row">
      <div class="col-sm-12">
         <section class="panel">
            <header class="panel-heading">
               Thêm mới <?=$module_name?>
               <?php $form = new form();?>
               
               <?=$form->textnote('Các trường có dấu (<span class="form-asterick">*</span>) là bắt buộc nhập')?>
            </header>  
            <div class="panel-body">
               <?print_error_msg($bg_errorMsg)?>
               <?=$form->form_open()?>
               <?=$form->select(array('label'=>'Loại sản phẩm',
                                      'name'=>'pro_type', 
                                      'id'=>'pro_type',
                                      'option'=>$arr_type, 
                                      'title'=>'Chọn hãng',
                                      'require'=>1,
                                      'errorMsg'=>'Bạn chưa chọn hãng',
                                      'selected'=>getValue('pro_type','int','POST',1),
                                      'class'=>'col-sm-9'
               ))?>
               <?=$form->text(array('label'=>'Tiêu đề sản phẩm',
                                    'name'=>'pro_name',
                                    'id'=>'pro_name',
                                    'value'=>getValue('pro_name','str','POST',''),
                                    'require'=>1, 
                                    'errorMsg'=>'Bạn chưa nhập tiêu đề bài', 
                                    'class'=>'col-sm-9')
               )?>
                <?=$form->text(array('label'=>'Đường dẫn',
                                      'name'=>'pro_alias',
                                      'id'=>'pro_alias',
                                      'placeholder'=> 'Nếu bạn không nhập, đường dẫn sẽ tự lấy theo tiêu đề',
                                      'helptext'=>'"Đường dẫn" cho URL thân thiện hơn. Yêu cầu: là chữ thường, không dấu, nối nhau bằng dấu gạch ngang. Ví dụ: danh-muc-bai-viet',
                                      'class'=>'col-sm-9')
                )?>
                <script>
                    $("#pro_name").on("change",function(){
                        var title = $(this).val();
                        $.ajax({
                             type:'post',
                             url:'ajax.php',
                             data:{title:title,action:'alias'},
                             success:function(html){
                                 $('#pro_alias').val(html);
                             }
                         })
                    });
                 </script>
               <?=$form->select(array('label'=>'Hãng',
                                      'name'=>'pro_cat_id', 
                                      'id'=>'pro_cat_id',
                                      'option'=>$list_cat, 
                                      'title'=>'Chọn hãng',
                                      'require'=>1,
                                      'errorMsg'=>'Bạn chưa chọn hãng',
                                      'selected'=>getValue('pro_cat_id','int','POST',''),
                                      'class'=>'col-sm-9'
               ))?>
               <?=$form->text(array('label'=>'Ngày ra mắt',
                                    'name'=>'pro_release_date',
                                    'id'=>'pro_release_date',
                                    'value'=>getValue('pro_release_date','int','POST',0),
                                    'isdatepicker'=>1,
                                    'class'=>'col-sm-9')
               )?>
               <?=$form->showImagesGallery(array('label'=>'Ảnh đại diện',
                                                 'title'=>'Ảnh đại diện',
                                                 'name'=>'imu',
                                                 'id'=>'imu',
                                                 'class'=>'col-sm-9'))?>
               <?=$form->checkbox(array('label'=> 'Xuất bản', 
                                        'name'=> 'pro_active', 
                                        'id'=> 'pro_active', 
                                        'value'=>1 ,
                                        'currentValue'=>getValue('pro_active','int','POST',1), 
                                        'helptext'=> 'Xuất bản - hiển thị ra website',
                                        'class'=>'col-sm-9',
                                        'extra'=>' onclick="return check_one(\'pro_active\');"')
               )?>
               <?=$form->text(array('label'=>'Giá',
                                    'name'=>'pro_price',
                                    'id'=>'pro_price',
                                    'value'=>getValue('pro_price','int','POST',68000000),
                                    'placeholder'=>'Số nguyên. Vd: 4550000',
                                    'class'=>'col-sm-9')
               )?>
               <?=$form->text(array('label'=>'Bảo hành',
                                    'name'=>'pro_warranty',
                                    'id'=>'pro_warranty',
                                    'value'=>getValue('pro_warranty','str','POST',''),
                                    'placeholder'=>'Vd: 12 tháng',
                                    'class'=>'col-sm-9')
               )?>
               <?=$form->text(array('label'=>'Giá bảo hành vàng',
                                    'name'=>'pro_goldwarranty',
                                    'id'=>'pro_goldwarranty',
                                    'value'=>getValue('pro_goldwarranty','int','POST',0),
                                    'placeholder'=>'Số nguyên. Vd: 4550000 (không có bảo hành vào thì để số 0)',
                                    'class'=>'col-sm-9')
               )?>
               <?=$form->textarea(array('label'=> 'Khuyến mại', 
                                        'name'=> 'pro_promotion', 
                                        'id'=> 'pro_promotion',
                                        'value'=>getValue('pro_promotion','str','POST',''), 
                                        'style'=>'width:100%;height:100px', 
                                        'class'=>'col-sm-9')
               )?>
               <?=$form->select(array('label'=>'Trạng thái hàng',
                                      'name'=>'pro_instock_status', 
                                      'id'=>'pro_instock_status',
                                      'option'=>$list_instock_status, 
                                      'title'=>'Chọn trạng thái hàng',
                                      'require'=>1,
                                      'errorMsg'=>'Bạn chưa chọn trạng thái hàng',
                                      'selected'=>getValue('pro_instock_status','int','POST',0),
                                      'class'=>'col-sm-9'
               ))?>
               <?=$form->text(array('label'=>'Số lượng trong kho',
                                    'name'=>'pro_instock_number',
                                    'id'=>'pro_instock_number',
                                    'value'=>getValue('pro_instock_number','int','POST',0),
                                    'placeholder'=>'Số nguyên. Vd: 15',
                                    'class'=>'col-sm-9')
               )?>
              <?=$form->text(array(
                  'label'=>'Phụ kiện liên quan(4 phụ kiện)',
                  'name'=>'',
                  'placeholder'=>'Search theo hãng sản xuất, tên sp...',
                  'id'=>'search_pro_relate',
                  'extra'=>'onkeyup="ProductJS.search_relate()"',
                  'class'=>'col-sm-9'
              ))?>
              <div class="control-group">
                  <label class="control-label fl">&nbsp;</label>
                 <div class="controls col-sm-9">
                     <ul id="relate_pro_result" style="padding-bottom: 10px;"></ul>
                     <div id="pro_relate_after_search">

                     </div>
                 </div>
             </div>
             <div class="clear"></div>
               <?=$form->tinyMCE('Đóng gói sản phẩm', 
                                 'pro_package', 
                                 'pro_package', 
                                 getValue('pro_package','str','POST',''), 
                                 '100%'
               )?>
               <?=$form->tinyMCE('Chi tiết sản phẩm', 
                                 'pro_details', 
                                 'pro_details', 
                                 getValue('pro_details','str','POST',''), 
                                 '100%'
               )?>
               <?=$form->text(array('label'=>'Tags',
                                    'name'=>'pro_tags',
                                    'id'=>'pro_tags',
                                    'value'=>getValue('pro_tags','str','POST',''),
                                    'placeholder'=>'Các từ khóa liên quan đến bài này, cách nhau bởi dấu phẩy',
                                    'class'=>'col-sm-9')
               )?>
               <div class="alert alert-info" data-toggle="collapse" data-target="#media"><b>Media</b></div>
               <div id="media" class="collapse in">
                  <div class="form-group">
                     <label class="control-label fl">Thuộc tính màu</label>
                     <div class="controls col-sm-9">
                        <a class="btn" href="javascript:;" onclick="return add_attribute()">+ Thêm màu</a>
                        <div class="res_attribute">
                        
                        </div>
                     </div>
                  </div>
                  <div class="form-group">
                     <label class="control-label fl">Ảnh slides</label>
                     <div class="controls col-sm-9">
                        <div class="controls-slides">
                           <div class="workspace_box_img workspace_box_img1" data-count="1">
                              <a href="javascript:;" onclick="return showImagesGalleryItem('more','slides',1)">Thêm ảnh</a>
                           </div>
                        </div>
                     </div>
                  </div>
               <?=$form->text(array('label'=>'Video sản phẩm',
                                    'name'=>'pro_videos',
                                    'id'=>'pro_videos',
                                    'value'=>getValue('pro_videos','str','POST',''),
                                    'placeholder'=>'Vd: https://www.youtube.com/watch?v=fpizbgJOr1k;https://www.youtube.com/watch?v=FFvSdyzPVm4',
                                    'helptext'=>'Dán link video url từ youtube vào đây, có thể thêm nhiều url và phân cách với nhau bằng dấu chấm phẩy " ; "',
                                    'class'=>'col-sm-9')
               )?>
               </div>
               
               <div class="alert alert-info" data-toggle="collapse" data-target="#ttc"><b>Thông tin chung</b></div>
               <div id="ttc" class="collapse">
               <?=$form->select(array('label'=>'Hệ điều hành',
                                      'name'=>'pro_general_os', 
                                      'id'=>'pro_general_os',
                                      'option'=>$arr_os, 
                                      'selected'=>getValue('pro_general_os','str','POST','android'),
                                      'class'=>'col-sm-9'
               ))?>
               <?=$form->text(array('label'=>'Ngôn ngữ',
                                    'name'=>'pro_general_language',
                                    'id'=>'pro_general_language',
                                    'value'=>getValue('pro_general_language','str','POST',''),
                                    'placeholder'=>'Vd: Tiếng Việt, Tiếng Anh, Tiếng Nhật',
                                    'class'=>'col-sm-9')
               )?>
               </div>
               <div class="alert alert-info" data-toggle="collapse" data-target="#mh"><b>Màn hình</b></div>
               <div id="mh" class="collapse">
               <?=$form->text(array('label'=>'Loại màn hình',
                                    'name'=>'pro_display_type',
                                    'id'=>'pro_display_type',
                                    'value'=>getValue('pro_display_type','str','POST',''),
                                    'placeholder'=>'Vd: LED-backlit IPS LCD',
                                    'class'=>'col-sm-9')
               )?>
               <?=$form->text(array('label'=>'Màu màn hình',
                                    'name'=>'pro_display_color',
                                    'id'=>'pro_display_color',
                                    'value'=>getValue('pro_display_color','str','POST',''),
                                    'placeholder'=>'Vd: 16 triệu màu',
                                    'class'=>'col-sm-9')
               )?>
               <?=$form->text(array('label'=>'Chuẩn màn hình',
                                    'name'=>'pro_display_standard',
                                    'id'=>'pro_display_standard',
                                    'value'=>getValue('pro_display_standard','str','POST',''),
                                    'placeholder'=>'Vd: DVGA',
                                    'class'=>'col-sm-9')
               )?>
               <?=$form->text(array('label'=>'Độ phân giải',
                                    'name'=>'pro_display_resolution',
                                    'id'=>'pro_display_resolution',
                                    'value'=>getValue('pro_display_resolution','str','POST',''),
                                    'placeholder'=>'Vd: 640 x 1136 pixels',
                                    'class'=>'col-sm-9')
               )?>
               <?=$form->text(array('label'=>'Màn hình rộng(")',
                                    'name'=>'pro_display_width',
                                    'id'=>'pro_display_width',
                                    'value'=>getValue('pro_display_width','str','POST',''),
                                    'placeholder'=>'Vd: 5',
                                    'class'=>'col-sm-9')
               )?>
               <?=$form->text(array('label'=>'Công nghệ cảm ứng',
                                    'name'=>'pro_display_induction',
                                    'id'=>'pro_display_induction',
                                    'value'=>getValue('pro_display_induction','str','POST',''),
                                    'placeholder'=>'Vd: Cảm ứng điện dung đa điểm',
                                    'class'=>'col-sm-9')
               )?>
               </div>
               <div class="alert alert-info" data-toggle="collapse" data-target="#chqp"><b>Chụp hình - Quay phim</b></div>
               <div id="chqp" class="collapse">
               <?=$form->text(array('label'=>'Camera sau',
                                    'name'=>'pro_cam_primary',
                                    'id'=>'pro_cam_primary',
                                    'value'=>getValue('pro_cam_primary','str','POST',''),
                                    'placeholder'=>'Vd: 16 MP',
                                    'class'=>'col-sm-9')
               )?>
               <?=$form->text(array('label'=>'Camera trước',
                                    'name'=>'pro_cam_second',
                                    'id'=>'pro_cam_second',
                                    'value'=>getValue('pro_cam_second','str','POST',''),
                                    'placeholder'=>'Vd: 2 MP',
                                    'class'=>'col-sm-9')
               )?>
               <?=$form->select(array('label'=>'Đèn flash',
                                      'name'=>'pro_cam_flash', 
                                      'id'=>'pro_cam_flash',
                                      'option'=>array(0=>'Không',1=>'Có'), 
                                      'selected'=>getValue('pro_cam_flash','int','POST',0),
                                      'class'=>'col-sm-9'
               ))?>
               <?=$form->text(array('label'=>'Tính năng camera',
                                    'name'=>'pro_cam_feature',
                                    'id'=>'pro_cam_feature',
                                    'value'=>getValue('pro_cam_feature','str','POST',''),
                                    'placeholder'=>'Vd: Tự động lấy nét, chạm lấy nét. Nhận diện khuôn mặt, nụ cười. Chống rung',
                                    'class'=>'col-sm-9')
               )?>
               <?=$form->text(array('label'=>'Quay phim',
                                    'name'=>'pro_cam_filming',
                                    'id'=>'pro_cam_filming',
                                    'value'=>getValue('pro_cam_filming','str','POST',''),
                                    'placeholder'=>'Vd: Quay phim 4K 2160p@30fps',
                                    'class'=>'col-sm-9')
               )?>
               <?=$form->select(array('label'=>'Video Call',
                                      'name'=>'pro_cam_videocall', 
                                      'id'=>'pro_cam_videocall',
                                      'option'=>array(0=>'Không',1=>'Có'), 
                                      'selected'=>getValue('pro_cam_videocall','int','POST',0),
                                      'class'=>'col-sm-9'
               ))?>
               </div>
               <div class="alert alert-info" data-toggle="collapse" data-target="#cpuram"><b>CPU - RAM</b></div>
               <div id="cpuram" class="collapse">
               <?=$form->text(array('label'=>'Tốc độ CPU',
                                    'name'=>'pro_cpuram_speed',
                                    'id'=>'pro_cpuram_speed',
                                    'value'=>getValue('pro_cpuram_speed','str','POST',''),
                                    'placeholder'=>'Vd: Quad-core 1.3 GHz Cortex-A53 & 1.9GHz quad-core Cortex-A57',
                                    'class'=>'col-sm-9')
               )?>
               <?=$form->text(array('label'=>'Số nhân',
                                    'name'=>'pro_cpuram_core',
                                    'id'=>'pro_cpuram_core',
                                    'value'=>getValue('pro_cpuram_core','str','POST',''),
                                    'placeholder'=>'Vd: 8 nhân',
                                    'class'=>'col-sm-9')
               )?>
               <?=$form->text(array('label'=>'Chipset',
                                    'name'=>'pro_cpuram_chipset',
                                    'id'=>'pro_cpuram_chipset',
                                    'value'=>getValue('pro_cpuram_chipset','str','POST',''),
                                    'placeholder'=>'Vd: Exynos 5433',
                                    'class'=>'col-sm-9')
               )?>
               <?=$form->text(array('label'=>'RAM',
                                    'name'=>'pro_cpuram_ram',
                                    'id'=>'pro_cpuram_ram',
                                    'value'=>getValue('pro_cpuram_ram','str','POST',''),
                                    'placeholder'=>'Vd: 2 GB',
                                    'class'=>'col-sm-9')
               )?>
               <?=$form->text(array('label'=>'Chip đồ họa (GPU)',
                                    'name'=>'pro_cpuram_graphic',
                                    'id'=>'pro_cpuram_graphic',
                                    'value'=>getValue('pro_cpuram_graphic','str','POST',''),
                                    'placeholder'=>'Vd: Mali-T760',
                                    'class'=>'col-sm-9')
               )?>
               </div>
               <div class="alert alert-info" data-toggle="collapse" data-target="#bnlt"><b>Bộ nhớ - Lưu trữ</b></div>
               <div id="bnlt" class="collapse">
               <?=$form->text(array('label'=>'Danh bạ',
                                    'name'=>'pro_storage_contacts',
                                    'id'=>'pro_storage_contacts',
                                    'value'=>getValue('pro_storage_contacts','str','POST',''),
                                    'placeholder'=>'Vd: không giới hạn',
                                    'class'=>'col-sm-9')
               )?>
               <?=$form->text(array('label'=>'Bộ nhớ trong(ROM)',
                                    'name'=>'pro_storage_rom',
                                    'id'=>'pro_storage_rom',
                                    'value'=>getValue('pro_storage_rom','str','POST',''),
                                    'placeholder'=>'Vd: 32 GB',
                                    'class'=>'col-sm-9')
               )?>
               <?=$form->text(array('label'=>'Thẻ nhớ ngoài',
                                    'name'=>'pro_storage_memorycard',
                                    'id'=>'pro_storage_memorycard',
                                    'value'=>getValue('pro_storage_memorycard','str','POST',''),
                                    'placeholder'=>'Vd: MicroSD (T-Flash)',
                                    'class'=>'col-sm-9')
               )?>
               <?=$form->text(array('label'=>'Hỗ trợ thẻ tối đa',
                                    'name'=>'pro_storage_memorycardsupport',
                                    'id'=>'pro_storage_memorycardsupport',
                                    'value'=>getValue('pro_storage_memorycardsupport','str','POST',''),
                                    'placeholder'=>'Vd: 128 GB',
                                    'class'=>'col-sm-9')
               )?>
               </div>
               <div class="alert alert-info" data-toggle="collapse" data-target="#tktl"><b>Thiết kế - Trọng lượng</b></div>
               <div id="tktl" class="collapse">
               <?=$form->text(array('label'=>'Kiểu dáng',
                                    'name'=>'pro_design_style',
                                    'id'=>'pro_design_style',
                                    'value'=>getValue('pro_design_style','str','POST',''),
                                    'placeholder'=>'Vd: Thanh + Cảm ứng',
                                    'class'=>'col-sm-9')
               )?>
               <?=$form->text(array('label'=>'Kích thước',
                                    'name'=>'pro_design_size',
                                    'id'=>'pro_design_size',
                                    'value'=>getValue('pro_design_size','str','POST',''),
                                    'placeholder'=>'Vd: 153.5 x 78.6 x 8.5 mm',
                                    'class'=>'col-sm-9')
               )?>
               <?=$form->text(array('label'=>'Trọng lượng(g)',
                                    'name'=>'pro_design_weight',
                                    'id'=>'pro_design_weight',
                                    'value'=>getValue('pro_design_weight','int','POST',0),
                                    'placeholder'=>'Vd: 132',
                                    'class'=>'col-sm-9')
               )?>
               </div>
               <div class="alert alert-info" data-toggle="collapse" data-target="#pin"><b>Pin</b></div>
               <div id="pin" class="collapse">
               <?=$form->text(array('label'=>'Loại',
                                    'name'=>'pro_pin_type',
                                    'id'=>'pro_pin_type',
                                    'value'=>getValue('pro_pin_type','str','POST',''),
                                    'placeholder'=>'Vd: Pin chuẩn Li-Ion',
                                    'class'=>'col-sm-9')
               )?>
               <?=$form->text(array('label'=>'Dung lượng',
                                    'name'=>'pro_pin_capacity',
                                    'id'=>'pro_pin_capacity',
                                    'value'=>getValue('pro_pin_capacity','str','POST',''),
                                    'placeholder'=>'Vd: 3220mAh',
                                    'class'=>'col-sm-9')
               )?>
               <?=$form->select(array('label'=>'Có thể tháo rời',
                                      'name'=>'pro_pin_removable', 
                                      'id'=>'pro_pin_removable',
                                      'option'=>array(0=>'Không',1=>'Có'), 
                                      'selected'=>getValue('pro_pin_removable','int','POST',0),
                                      'class'=>'col-sm-9'
               ))?>
               </div>
               <div class="alert alert-info" data-toggle="collapse" data-target="#kn"><b>Kết nối</b></div>
               <div id="kn" class="collapse">
               <?=$form->text(array('label'=>'3G',
                                    'name'=>'pro_connect_3g',
                                    'id'=>'pro_connect_3g',
                                    'value'=>getValue('pro_connect_3g','str','POST',''),
                                    'placeholder'=>'Vd: HSDPA, 42 Mbps; HSUPA, 5.76 Mbps',
                                    'class'=>'col-sm-9')
               )?>
               <?=$form->text(array('label'=>'4G',
                                    'name'=>'pro_connect_4g',
                                    'id'=>'pro_connect_4g',
                                    'value'=>getValue('pro_connect_4g','str','POST',''),
                                    'placeholder'=>'Vd: Có',
                                    'class'=>'col-sm-9')
               )?>
               <?=$form->text(array('label'=>'Loại sim',
                                    'name'=>'pro_connect_simtype',
                                    'id'=>'pro_connect_simtype',
                                    'value'=>getValue('pro_connect_simtype','str','POST',''),
                                    'placeholder'=>'Vd: Micro SIM',
                                    'class'=>'col-sm-9')
               )?>
               <?=$form->text(array('label'=>'2 sim 2 sóng',
                                    'name'=>'pro_connect_duasim',
                                    'id'=>'pro_connect_duasim',
                                    'value'=>getValue('pro_connect_duasim','str','POST',''),
                                    'placeholder'=>'Vd: 1 Sim',
                                    'class'=>'col-sm-9')
               )?>
               <?=$form->text(array('label'=>'Wifi',
                                    'name'=>'pro_connect_wifi',
                                    'id'=>'pro_connect_wifi',
                                    'value'=>getValue('pro_connect_wifi','str','POST',''),
                                    'placeholder'=>'Vd: Wi-Fi 802.11 a/b/g/n/ac, dual-band, DLNA, Wi-Fi Direct, Wi-Fi hotspot',
                                    'class'=>'col-sm-9')
               )?>
               <?=$form->text(array('label'=>'GPS',
                                    'name'=>'pro_connect_gps',
                                    'id'=>'pro_connect_gps',
                                    'value'=>getValue('pro_connect_gps','str','POST',''),
                                    'placeholder'=>'Vd: A-GPS',
                                    'class'=>'col-sm-9')
               )?>
               <?=$form->text(array('label'=>'Bluetoutch',
                                    'name'=>'pro_connect_bluetouth',
                                    'id'=>'pro_connect_bluetouth',
                                    'value'=>getValue('pro_connect_bluetouth','str','POST',''),
                                    'placeholder'=>'Vd: Có, V4.0 với A2DP, EDR',
                                    'class'=>'col-sm-9')
               )?>
               <?=$form->select(array('label'=>'GPRS/EDGE',
                                      'name'=>'pro_connect_gprs', 
                                      'id'=>'pro_connect_gprs',
                                      'option'=>array(0=>'Không',1=>'Có'), 
                                      'selected'=>getValue('pro_connect_gprs','int','POST',0),
                                      'class'=>'col-sm-9'
               ))?>
               <?=$form->select(array('label'=>'NFC',
                                      'name'=>'pro_connect_nfc', 
                                      'id'=>'pro_connect_nfc',
                                      'option'=>array(0=>'Không',1=>'Có'), 
                                      'selected'=>getValue('pro_connect_nfc','int','POST',0),
                                      'class'=>'col-sm-9'
               ))?>
               <?=$form->text(array('label'=>'Jack tai nghe',
                                    'name'=>'pro_connect_jack',
                                    'id'=>'pro_connect_jack',
                                    'value'=>getValue('pro_connect_jack','str','POST',''),
                                    'placeholder'=>'Vd: 3.5 mm',
                                    'class'=>'col-sm-9')
               )?>
               <?=$form->text(array('label'=>'Kết nối USB',
                                    'name'=>'pro_connect_usb',
                                    'id'=>'pro_connect_usb',
                                    'value'=>getValue('pro_connect_usb','str','POST',''),
                                    'placeholder'=>'Vd: Có',
                                    'class'=>'col-sm-9')
               )?>
               <?=$form->text(array('label'=>'Kết nối khác',
                                    'name'=>'pro_connect_other',
                                    'id'=>'pro_connect_other',
                                    'value'=>getValue('pro_connect_other','str','POST',''),
                                    'placeholder'=>'Vd: NFC',
                                    'class'=>'col-sm-9')
               )?>
               <?=$form->text(array('label'=>'Cổng sạc',
                                    'name'=>'pro_connect_chargprot',
                                    'id'=>'pro_connect_chargprot',
                                    'value'=>getValue('pro_connect_chargprot','str','POST',''),
                                    'placeholder'=>'Vd: Micro USB',
                                    'class'=>'col-sm-9')
               )?>
               </div>
               <div class="alert alert-info" data-toggle="collapse" data-target="#gtud"><b>Giải trí - Ứng dụng</b></div>
               <div id="gtud" class="collapse">
               <?=$form->text(array('label'=>'Xem phim',
                                    'name'=>'pro_entertainment_movie',
                                    'id'=>'pro_entertainment_movie',
                                    'value'=>getValue('pro_entertainment_movie','str','POST',''),
                                    'placeholder'=>'Vd: MP4, WMV, H.263, H.264(MPEG4-AVC), Xvid, DivX',
                                    'class'=>'col-sm-9')
               )?>
               <?=$form->text(array('label'=>'Nghe nhạc',
                                    'name'=>'pro_entertainment_player',
                                    'id'=>'pro_entertainment_player',
                                    'value'=>getValue('pro_entertainment_player','str','POST',''),
                                    'placeholder'=>'Vd: MP3, WAV, WMA, eAAC+, AC3, FLAC',
                                    'class'=>'col-sm-9')
               )?>
               <?=$form->select(array('label'=>'Ghi âm',
                                      'name'=>'pro_entertainment_recording', 
                                      'id'=>'pro_entertainment_recording',
                                      'option'=>array(0=>'Không',1=>'Có'), 
                                      'selected'=>getValue('pro_entertainment_recording','int','POST',0),
                                      'class'=>'col-sm-9'
               ))?>
               <?=$form->select(array('label'=>'FM radio',
                                      'name'=>'pro_entertainment_fm', 
                                      'id'=>'pro_entertainment_fm',
                                      'option'=>array(0=>'Không',1=>'Có'), 
                                      'selected'=>getValue('pro_entertainment_fm','int','POST',0),
                                      'class'=>'col-sm-9'
               ))?>
               <?=$form->textarea(array('label'=> 'Chức năng khác', 
                                        'name'=> 'pro_entertainment_other', 
                                        'id'=> 'pro_entertainment_other',
                                        'value'=>getValue('pro_entertainment_other','str','POST',''), 
                                        'style'=>'width:100%;height:100px', 
                                        'class'=>'col-sm-9')
               )?>
               
               </div>
               
               <?=$form->seoMeta($bg_table)?>
               <?=$form->form_action_add()?>
               <?=$form->form_close()?>
            </div> 
         </section>
      </div>
   </div>  
</div>
<script>
function removeImagesGallery(idclass) {
   $('.workspace_box_img'+idclass).remove();
}
var num = 0;
 function add_attribute(){
     num++;
     $('.res_attribute').append('<div class="control-group"><div class="controls"><input type="hidden" name="attribute_val[]" value="'+num+'"/><input type="color" name="attribute_color_'+num+'"/><input type="text" name="attribute_price_'+num+'" placeholder="Giá sản phẩm màu này"/><a href="javascript:;" class="attribute_rm"> Xóa thuộc tính</a></div></div>');
 }
 $('.res_attribute').on('click','.attribute_rm',function(){
   var attribute_rm_sls = $(this).closest('.control-group');
   attribute_rm_sls.remove();
 });
</script>
</body>
</html>